﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Collections;
using System.Windows.Forms;


namespace Pharmacy_management_system
{
    class zhiliaoyongyaofp
    {
        public static DataSet dubiao(string cuan, String sqlyj, string sqltj)
        {

            SqlConnection sql = new SqlConnection(cuan);
            sql.Open();
            SqlDataAdapter da = new SqlDataAdapter(sqlyj + sqltj, sql);
            DataSet ds = new DataSet();
            da.Fill(ds);

            //DataTable dt = new DataTable();
            //da.Fill(dt);
            return (ds);


        }
        //治疗用药点评读取点评信息。
        public void Therapeuticusepj(string zifuc, int zhuangtai, Label[] label1, RadioButton[] radiobutton1, string row1, ArrayList dny, TextBox t)
        {
            using (SqlConnection sql = new SqlConnection(zifuc))
            {
                try
                {
                    sql.Open();
                    SqlCommand one = sql.CreateCommand();
                    one.CommandText = "select user_name,time,i_level,c_question from zl_main where case_id = '" + row1 + "'";
                    SqlDataReader dr = one.ExecuteReader();
                    if (dr.HasRows)
                    {
                        zhuangtai = 1;
                        dr.Read();
                        label1[0].Text = "评价人：" + dr[0].ToString();
                        label1[1].Text = dr[1].ToString();
                        if (dr[2].ToString() == "1")
                        {

                            radiobutton1[0].Checked = true;
                            label1[2].Text = "评价结果：" + "不合理";
                        }
                        else if (dr[2].ToString() == "0")
                        {
                            radiobutton1[1].Checked = true;
                            t.Text = dr[3].ToString();
                            label1[2].Text = "评价结果：" + "合理";
                        }
                        one.CommandText = "select evl_id from zl_detail where case_id ='" + row1 + "'";
                        dr = one.ExecuteReader();
                        while (dr.Read())
                        {
                            foreach (CheckBox d in dny)
                            {
                                if (d.Name == "pingjia" + dr[0].ToString())
                                {
                                    d.Checked = true;
                                    break;
                                }
                            }

                        }
                    }
                    else
                    {
                        zhuangtai = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                }
                finally
                {
                    sql.Close();
                }
                
            }
        }
       
    }
}
